package ${packageUrl};

import com.kyexpress.framework.utils.StringUtils;

/**
 * @description: ${description}  ${lookUpCode}
 * @author: ${author}
 * @date: create in ${dateTime}
 */
public enum ${fileName} {

    <#list dictList as dict>
    ${dict.fieldName}("${dict.dictKey}","${dict.dictValue}"),
    </#list>
    ;

    /** key- 编码 */
    private String key;

    /** value 编码描述 */
    private String value;


    ${fileName}(String key, String value ) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }


    /**
     * 根据key获取value
     *
     * @param key 键
     * @return key对应的value
     */
    public static String getValueByKey(String key) {
        if (key == null) {
            return "";
        }
        for (${fileName} e : values()) {
            if (e.getKey().equals(key)) {
                return e.getValue();
            }
        }
        return "";
    }

    /**
     * 根据value获取key
     *
     * @param value 值
     * @return value对应的key
     */
    public static String getKeyByValue(String value) {
        if (StringUtils.isEmpty(value)) {
            return null;
        }
        for (${fileName} e : values()) {
            if (e.getValue().equals(value)) {
                return e.getKey();
            }
        }
        return null;
    }
}
